//
//  KLPeerLocal.h
//  WebRTCDemo_iOS
//
//  Created by szblsx2 on 2020/3/5.
//  Copyright © 2020 szblsx2. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KLAppDefine.h"
@class KLClient;
@class KLPeerLocal;

NS_ASSUME_NONNULL_BEGIN

@protocol KLPeerLocalDelegate <NSObject>

@required
// 采集到本地视频源
- (void)klPeerLocal:(KLPeerLocal *)peerLocal capturerSession:(AVCaptureSession *)captureSession;

@end

@interface KLPeerLocal : NSObject
//房间id
@property (nonatomic, copy) NSString *roomId;
//当前连接流id
@property (nonatomic, copy) NSString *streamId;
//入会信息
@property (nonatomic, strong) KLMeetUser *localUser;
//delegate
@property (nonatomic, weak) id<KLPeerLocalDelegate> delegate;
//事件回调
@property (nonatomic, copy) void(^eventHandleBlock)(NSDictionary *response);

/**
*  初始化PeerLocal
*  @param client          信令对象
*  @param factory        连接工厂
*  @param iceServers  ice服务器地址集合
*/
- (instancetype)initWithClient:(KLClient *)client
                         factory:(RTCPeerConnectionFactory *)factory
                      iceServers:(NSArray<RTCIceServer *>*)iceServers;

/**
*  初始化音视频采集
*/
- (void)initCapturer;

/**
*  停止音视频采集
*/
- (void)freeCapture;

/**
*  创建PeerConnection
*/
- (void)initPeerConnection;

/**
*  删除PeerConnection
*/
- (void)freePeerConnection;

/**
*  创建offer SDP
*/
- (void)createOffer;

/**
*  接收到远端answer SDP处理
*  @param sessionDescription    远端sdp描述
*/
- (void)onRemoteDescription:(RTCSessionDescription *)sessionDescription;

/**
*  发送停止推流
*/
- (void)sendUnPublish;

/**
*  是否打开摄像头 默认开启
*  @param open 是否开启
*/
- (void)turnOnCamera:(BOOL)open;

/**
*  切换前后置摄像头 默认前置
*/
- (void)switchCamera;

/**
*  是否打开麦克风 默认开启
*  @param open 是否开启
*/
- (void)turnOnMicrophone:(BOOL)open;

/**
*  是否开启扬声器
*  @param open 默认开启
*/
- (void)whetherToOpenLoudspeaker:(BOOL)open;

@end

NS_ASSUME_NONNULL_END
